{% load origin %}
{% load ietf_filters session_filters %}
{% origin %}
<table class="table table-sm table-striped tablesorter">
    <thead>
        <tr>
            <th scope="col" data-sort="revision">Revision</th>
            <th scope="col" data-sort="meeting">Meeting</th>
            <th scope="col" data-sort="session">Session</th>
            <th scope="col">{# Agenda #}</th>
            <th scope="col">{# Minutes #}</th>
            <th scope="col">{# Buttons #}</th>
        </tr>
    </thead>
    <tbody>
        {% for s in sessions %}
            <tr>
                <td>{{ s|presented_versions:doc }}</td>
                <td>
                    {% ifchanged s.meeting %}
                        {% if s.meeting.type.slug == 'ietf' %}IETF{% endif %}
                        {{ s.meeting.number }}
                    {% endifchanged %}
                </td>
                <td>
                    {% if s.name %}
                        {{ s.name }}
                        <br>
                    {% else %}
                        {{ s.group.acronym }} -
                    {% endif %}
                    {% if s.current_status == "sched" %}
                        {% if s.meeting.type.slug == 'ietf' %}
                            {{ s.time|date:"D M d, Y Hi" }}
                        {% else %}
                            {{ s.time|date:"D M d, Y" }}
                        {% endif %}
                    {% else %}
                        {{ s.current_status_name }}
                    {% endif %}
                </td>
                <td>
                    {% if s.agenda %}<a href="{{ s.agenda.get_absolute_url }}">Agenda</a>{% endif %}
                </td>
                <td>
                    {% if s.minutes %}<a href="{{ s.minutes.get_absolute_url }}">Minutes</a>{% endif %}
                </td>
                <td>
                    <a href="{% url 'ietf.meeting.views.session_details' num=s.meeting.number acronym=s.group.acronym %}"
                       class="btn btn-sm btn-primary">
                        Materials
                    </a>
                    {% if user|has_role:"Secretariat" or s|can_manage_materials:user and not s.is_material_submission_cutoff %}
                        <a class="btn btn-{% if s.is_material_submission_cutoff %}warning{% else %}primary{% endif %} btn-sm"
                           href="{% url 'ietf.doc.views_doc.remove_sessionpresentation' name=doc.name session_id=s.pk %}">
                            Remove document from session
                        </a>
                        <a class="btn btn-{% if s.is_material_submission_cutoff %}warning{% else %}primary{% endif %} btn-sm"
                           href="{% url 'ietf.doc.views_doc.edit_sessionpresentation' name=doc.name session_id=s.pk %}">
                            Change revision
                        </a>
                    {% endif %}
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
